import request from "@/util/request";

/**
 * 获取所有分类列表
 */
export const listAllCategory = () => {
    return request({
        url: '/category/listAll',
        method: 'GET',
        headers: {
            'token': localStorage.getItem('token')
        }
    });
};

/**
 * 添加分类
 */
export const addStore = (data: {
    name: string;
    parentId: number;
}) => {
    return request({
        url: '/category/add',
        method: 'POST',
        headers: {
            'token': localStorage.getItem('token')
        },
        data
    });
};

/**
 * 删除分类
 */
export const delCategory = (id: number) => {
    return request({
        url: '/category/del',
        method: 'GET',
        headers: {
            'token': localStorage.getItem('token')
        },
        params: {
            "id": id
        }
    });
};

/**
 * 修改分类
 */
export const modifyCategory = (data: {
    id: number;
    name: string;
    parentId: number;
    sort: number;
}) => {
    return request({
        url: '/category/modify',
        method: 'POST',
        headers: {
            'token': localStorage.getItem('token')
        },
        data
    });
};
